//
//  PKOSSUtils.swift
//  Panku
//
//  Created by mac on 2017/4/13.
//  Copyright © 2017年 Monster. All rights reserved.
//

import UIKit
import ReactiveCocoa
import ReactiveSwift
import Result

class PKOSSUtils: NSObject {
    
    //上传 data
    class func upload(data:Data,success:@escaping ((Any?, String?) -> Void),failure:@escaping ((Error?) -> Void)) -> Void{
        
        let oss_bucketName = PKConfigServices.oss_bucketName()
        let objectKey = NSDate.urlStringNow()
        
        PKRequestTool.shareInstance().asyncUploadObjectWithbucketName(oss_bucketName, objectKey: objectKey, data: data, success: success, failure: failure)
        
    }
    
    //上传 file url
    class func upload(url:URL,success:@escaping ((Any?, String?) -> Void),failure:@escaping ((Error?) -> Void)) -> Void{
        
        let oss_bucketName = PKConfigServices.oss_bucketName()
        let objectKey = NSDate.urlStringNow()
        let urlString = url.absoluteString
        PKRequestTool.shareInstance().asyncUploadObjectWithbucketName(oss_bucketName, objectKey: objectKey, filePath: urlString, success: success, failure: failure)
        
    }
}
